FROM sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/node:14.20.0-alpine3.15 AS build
COPY ./ /app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk add --update --no-cache zip
WORKDIR /app
RUN npm install --registry=https://registry.npmmirror.com
RUN npm run build:docker
RUN cd /app/docker/dist && zip -r /app/build.zip ./ 

FROM sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/alpine:latest AS release
COPY ./nginx.conf /etc/nginx/nginx.conf
RUN mkdir /app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && apk add --update --no-cache nginx zip

COPY --from=build /app/build.zip /app/build.zip
RUN cd /app && unzip build.zip && rm -rf build.zip
ENTRYPOINT ["nginx"]

